<?php

namespace App\Http\Repository;

use App\ApiLog as ModelApiLog;
use App\ApiLogContent;

class ApiLogRepository
{
    static public function Log($request, $response)
    {
        $model_api_log = new ModelApiLog();
        $model_api_log->ip = $request->getClientIp();
        $model_api_log->method = $request->method();
        $model_api_log->path = $request->path();
        $model_api_log->status = $response->getStatusCode();
        $model_api_log->save();

        $api_log_content = new ApiLogContent();
        $api_log_content->api_log_id = $model_api_log->id;
        $api_log_content->resquest = json_encode($request->all());
        $api_log_content->response = json_encode($response->getContent());
        $api_log_content->save();
    }
}
